package com.neusoft.lohas.modules.ivm.entity.order;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.neusoft.lohas.common.persistence.IdEntity;
import com.neusoft.lohas.modules.sys.entity.User;

/**
 * 用户收货地址Entity
 * @author Jackie.Liu
 * @version 2014-12-16
 */
@Entity
@Table(name = "ivm_user_address")
@DynamicInsert @DynamicUpdate
public class UserAddress extends IdEntity<UserAddress>{

	private static final long serialVersionUID = 1L;
	private User user; //所属用户
	private String name; //收货人姓名
	private String phone; //收货人手机号
	private String province; //地址（省份）
	private String city; //地址（市）
	private String county; //地址（区、县）
	private String address; //详细地址
	private int defaultFlag; //是否设为默认地址：0否，1是
	
	public UserAddress() {
		super();
	}

	public UserAddress(String id){
		this();
		this.id = id;
	}

	@ManyToOne
	@JoinColumn(name="user_id")
	@NotFound(action = NotFoundAction.IGNORE)
	@NotNull(message="所属用户不能为空")
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getCounty() {
		return county;
	}

	public void setCounty(String county) {
		this.county = county;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public int getDefaultFlag() {
		return defaultFlag;
	}

	public void setDefaultFlag(int defaultFlag) {
		this.defaultFlag = defaultFlag;
	}
	
	@Transient
	public String getDetailAddress(){
		return this.city+this.county+this.address;
	}
	
}
